from tkinter import *
from aip import AipOcr
class dic:
    config={}
    def __init__(self):
        self.config['type']=11
        self.config['dic']=2
        self.config['count']={"label":"御魂次数：","value":200,"row":0,"column":0}
    def get(self):
        return  self.config    

class app(Tk):
    containers={}
    def __init__(self,dic):
        self.config=dic.get()
        self.app=Tk()
        self.app.title('阴阳师')
        self.layout()
        self.app.mainloop()
    def layout(self):
        self.addInput(self.config['count'],'count')
        Button(self.app,text="开始",command=self.submit).grid(row=1,column=1)
    def addInput(self,container,name):
        Label(self.app,text=container['label']).grid(row=container['row'],column=container['column'])
        self.containers[name]=Entry(self.app,textvariable=StringVar(self.app,container['value']))
        self.containers[name].grid(row=0,column=1)
    def submit(self):
        self.config['count']=self.containers['count'].get()
        sc=script(self.config).run()

class script:
    def __init__(self,config):
        self.config=config
    def run(self):
        print(self.config)    

class  baiduAPi:
    def __init__(self):
        self.appId="16710751"
        self.appKey="NIzdy3wjtI4wGwF3oI4NEP9f"
        self.secretkey="polf09BE2WleBwYVHSdmZSQad5hrwDDA"
        self.client = AipOcr(self.appId,self.appKey, self.secretKey)
    def find(url):
        self.client 
        options = {}
        options["language_type"] = "CHN_ENG"
        options["detect_direction"] = "true"
        options["detect_language"] = "true"
        options["probability"] = "true"
        if(string.find(url,"http")!=-1):
            print(111)
        else:
            print(222)
    def file_get_content(url):
        with open(filePath, 'rb') as fp:
            return fp.read()        
application=app(dic())                
